//package cc.magicjson.summary.errors.connection.closed.monitor;
//
//import org.aspectj.lang.ProceedingJoinPoint;
//import org.aspectj.lang.annotation.Around;
//import org.aspectj.lang.annotation.Aspect;
//import org.aspectj.lang.reflect.MethodSignature;
//import org.springframework.core.annotation.Order;
//import org.springframework.stereotype.Component;
//import org.springframework.transaction.annotation.Transactional;
//
//@Aspect
//@Component
//@Order(1)
//public class TransactionalDbMonitor {
//
//    @Around("@annotation(org.springframework.transaction.annotation.Transactional) && " +
//            "execution(* cc.magicjson.summary.errors.connection.closed.service.impl.*.*(..))")
//    public Object monitorTransactionalDbOperation(ProceedingJoinPoint joinPoint) throws Throwable {
//        MethodSignature signature = (MethodSignature) joinPoint.getSignature();
//        String className = joinPoint.getTarget().getClass().getSimpleName();
//        String methodName = signature.getMethod().getName();
//        Transactional transactional = signature.getMethod().getAnnotation(Transactional.class);
//
//        long startTime = System.currentTimeMillis();
//        try {
//            Object result = joinPoint.proceed();
//            long endTime = System.currentTimeMillis();
//            TransactionLogger.info(String.format(
//                "[DB-Transaction] Class: %s, Method: %s, Propagation: %s, Time cost: %d ms",
//                className, methodName, transactional.propagation(), (endTime - startTime))
//            );
//            return result;
//        } catch (Throwable e) {
//            long endTime = System.currentTimeMillis();
//            TransactionLogger.error(String.format(
//                "[DB-Transaction] Class: %s, Method: %s, Propagation: %s, Time cost: %d ms",
//                className, methodName, transactional.propagation(), (endTime - startTime)), e
//            );
//            throw e;
//        }
//    }
//}
